@njuptlzf/agent-chat-web 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgentChat.d.ts +7 -1
- package/dist/AgentChat.js +23 -5
- package/dist/AgentChatApp.d.ts +4 -1
- package/dist/AgentChatApp.js +2 -2
- package/dist/PersonasPage.js +8 -0
- package/dist/assets/_commonjs-dynamic-modules-TDtrdbi3.js +1 -0
- package/dist/assets/exceljs.min-jlEt4kSc.js +29 -0
- package/dist/assets/index-B7uSE8SM.css +1 -0
- package/dist/assets/index-D57mU5H5.js +50 -0
- package/dist/assets/index-Dviy7gnB.js +44 -0
- package/dist/assets/pdf-CfhDiWmk.js +55 -0
- package/dist/assets/pdf.worker.min-CdXBBzB4.js +1 -0
- package/dist/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
- package/dist/index.html +13 -0
- package/dist/mount.d.ts +7 -1
- package/dist/mount.js +2 -2
- package/dist/styles.css +1492 -1478
- package/dist/suggestions.d.ts +41 -0
- package/dist/suggestions.js +98 -0
- package/dist/ui/FollowUpSuggestions.d.ts +9 -0
- package/dist/ui/FollowUpSuggestions.js +13 -0
- package/dist/ui/Icon.d.ts +8 -0
- package/dist/ui/Icon.js +26 -0
- package/dist/ui/icons.d.ts +19 -0
- package/dist/ui/icons.js +25 -0
- package/dist/ui/slots.d.ts +23 -0
- package/dist/ui/slots.js +13 -0
- package/package.json +71 -72
- package/src/App.tsx +13 -13
- package/src/agent-chat/AgentChat.tsx +729 -692
- package/src/agent-chat/AgentChatApp.tsx +211 -206
- package/src/agent-chat/PersonasPage.tsx +705 -678
- package/src/agent-chat/adapter.ts +272 -272
- package/src/agent-chat/app-def-check.ts +215 -215
- package/src/agent-chat/app.tsx +327 -327
- package/src/agent-chat/auth.ts +83 -83
- package/src/agent-chat/dock.ts +161 -161
- package/src/agent-chat/docs.ts +179 -179
- package/src/agent-chat/index.ts +17 -17
- package/src/agent-chat/mount.tsx +8 -1
- package/src/agent-chat/qual.ts +55 -55
- package/src/agent-chat/sse.ts +104 -104
- package/src/agent-chat/suggestions.ts +127 -0
- package/src/agent-chat/theme.ts +23 -23
- package/src/agent-chat/ui/CodeCopyHeader.tsx +29 -29
- package/src/agent-chat/ui/ConfirmCard.tsx +32 -32
- package/src/agent-chat/ui/FollowUpSuggestions.tsx +28 -0
- package/src/agent-chat/ui/Icon.tsx +53 -0
- package/src/agent-chat/ui/Lightbox.tsx +32 -32
- package/src/agent-chat/ui/QueueBar.tsx +70 -70
- package/src/agent-chat/ui/Splitter.tsx +81 -81
- package/src/agent-chat/ui/ThemeToggle.tsx +25 -25
- package/src/agent-chat/ui/TierPicker.tsx +112 -112
- package/src/agent-chat/ui/UIPromptCard.tsx +68 -68
- package/src/agent-chat/ui/icons.ts +31 -0
- package/src/agent-chat/ui/slots.tsx +35 -0
- package/src/agent-chat/ui/timefmt.ts +110 -110
- package/src/agent-chat/ui/useNarrow.ts +20 -20
- package/src/fake-product/entry.tsx +63 -54
- package/src/main.tsx +8 -8
- package/src/styles.css +1492 -1478
package/dist/AgentChat.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { BrandingResponse, ChatCommand } from "@njuptlzf/agent-chat-protocol";
|
|
3
3
|
import { type ThreadMessageLike } from "@assistant-ui/react";
|
|
4
|
-
|
|
4
|
+
import { type Slots } from "./ui/slots.tsx";
|
|
5
|
+
export default function ChatApp({ branding, sessionId, initialMessages, tier, scope, renderCard, slots: slotsOverride, persona, title, policyNote, welcome, suggestions, commands, onRunEnd, onTier, }: {
|
|
5
6
|
branding: BrandingResponse;
|
|
6
7
|
sessionId?: string;
|
|
7
8
|
initialMessages?: readonly ThreadMessageLike[];
|
|
@@ -9,6 +10,11 @@ export default function ChatApp({ branding, sessionId, initialMessages, tier, sc
|
|
|
9
10
|
scope?: string;
|
|
10
11
|
/** 产物卡渲染器:由产品 AppDef 注入,core 不认识 details 的形状。 */
|
|
11
12
|
renderCard?: (details: unknown) => ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* 视觉件槽位覆盖(可插拔):产品可整体替换 Icon / FollowUpSuggestions;
|
|
15
|
+
* 不传 = 全部走平台默认实现。见 ui/slots.tsx 的槽位契约。
|
|
16
|
+
*/
|
|
17
|
+
slots?: Partial<Slots>;
|
|
12
18
|
/**
|
|
13
19
|
* 人格:随每条消息发给服务端;undefined = 产品默认助手。
|
|
14
20
|
* **id 由产品 manifest 声明**,core 不认识具体名字(通用化),
|
package/dist/AgentChat.js
CHANGED
|
@@ -3,6 +3,7 @@ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, use
|
|
|
3
3
|
import { ActionBarPrimitive, AuiIf, AssistantRuntimeProvider, ComposerPrimitive, MessagePrimitive, ThreadPrimitive, useAui, useAuiState, useLocalRuntime, useMessageTiming, } from "@assistant-ui/react";
|
|
4
4
|
import { MarkdownTextPrimitive } from "@assistant-ui/react-markdown";
|
|
5
5
|
import { createChatAdapter, dataUrlToImage, markEdit } from "./adapter.js";
|
|
6
|
+
import { createFollowUpAdapter, followUpConfigOf, resolveFollowUpMode } from "./suggestions.js";
|
|
6
7
|
import { docKind, docPart, fileToDoc, MAX_DOCS } from "./docs.js";
|
|
7
8
|
import { auth } from "./auth.js";
|
|
8
9
|
import { dockStore, subscribeChat } from "./dock.js";
|
|
@@ -11,10 +12,11 @@ import { ConfirmCard } from "./ui/ConfirmCard.js";
|
|
|
11
12
|
import CodeCopyHeader from "./ui/CodeCopyHeader.js";
|
|
12
13
|
import { Lightbox } from "./ui/Lightbox.js";
|
|
13
14
|
import { QueueBar } from "./ui/QueueBar.js";
|
|
15
|
+
import { resolveSlots, SlotsProvider, useSlots } from "./ui/slots.js";
|
|
14
16
|
import { TierPicker } from "./ui/TierPicker.js";
|
|
15
17
|
import ThemeToggle from "./ui/ThemeToggle.js";
|
|
16
18
|
import { UIPromptCard } from "./ui/UIPromptCard.js";
|
|
17
|
-
export default function ChatApp({ branding, sessionId, initialMessages, tier, scope, renderCard, persona, title, policyNote, welcome, suggestions, commands, onRunEnd, onTier, }) {
|
|
19
|
+
export default function ChatApp({ branding, sessionId, initialMessages, tier, scope, renderCard, slots: slotsOverride, persona, title, policyNote, welcome, suggestions, commands, onRunEnd, onTier, }) {
|
|
18
20
|
const [running, setRunning] = useState(false);
|
|
19
21
|
const [queue, setQueue] = useState([]);
|
|
20
22
|
const [usage, setUsage] = useState(null);
|
|
@@ -78,7 +80,22 @@ export default function ChatApp({ branding, sessionId, initialMessages, tier, sc
|
|
|
78
80
|
void postJson("/api/feedback", { sessionId: sid, rating: type === "positive" ? "up" : "down", ref: message.id }, auth.token).catch(() => { });
|
|
79
81
|
},
|
|
80
82
|
}), []);
|
|
81
|
-
|
|
83
|
+
// 下一步建议:生效模式 = 全局 off 硬地板 > 人格 followUpMode > 全局 mode > llm。
|
|
84
|
+
// adapter 必须 useMemo 稳定引用,否则每次 render 新对象会让库重复生成。
|
|
85
|
+
const followUpCfg = useMemo(() => followUpConfigOf(branding.ui?.followUp), [branding.ui?.followUp]);
|
|
86
|
+
const followUpMode = resolveFollowUpMode(branding, persona);
|
|
87
|
+
const followUpPersona = persona ?? branding.defaultPersona;
|
|
88
|
+
const suggestionAdapter = useMemo(() => (followUpMode === "off" ? undefined : createFollowUpAdapter(followUpCfg, followUpMode, followUpPersona)), [followUpCfg, followUpMode, followUpPersona]);
|
|
89
|
+
const slots = useMemo(() => resolveSlots(slotsOverride), [slotsOverride]);
|
|
90
|
+
const runtime = useLocalRuntime(adapter, {
|
|
91
|
+
initialMessages,
|
|
92
|
+
adapters: {
|
|
93
|
+
feedback: feedbackAdapter,
|
|
94
|
+
// off = 不挂载:库拿到 undefined 直接不生成,零开销。
|
|
95
|
+
...(suggestionAdapter ? { suggestion: suggestionAdapter } : {}),
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
const { FollowUpSuggestions } = useSlots();
|
|
82
99
|
const answerConfirm = useCallback((info, allow) => {
|
|
83
100
|
setConfirms((c) => c.filter((x) => x.toolCallId !== info.toolCallId));
|
|
84
101
|
void postDecision({ sessionId: info.sessionId, toolCallId: info.toolCallId, allow }, auth.token);
|
|
@@ -143,7 +160,7 @@ export default function ChatApp({ branding, sessionId, initialMessages, tier, sc
|
|
|
143
160
|
runtime.thread.cancelRun();
|
|
144
161
|
};
|
|
145
162
|
const drop = (i) => setQueue((q) => q.filter((_, j) => j !== i));
|
|
146
|
-
return (_jsx(AssistantRuntimeProvider, { runtime: runtime, children: _jsxs("div", { className: "chat", children: [_jsxs("header", { className: "chatbar", children: [branding.logo ? _jsx("img", { className: "logo", src: branding.logo, alt: "" }) : null, _jsx("h1", { children: title ?? branding.title }), _jsx(ThemeToggle, {})] }), policyNote && (_jsxs("p", { className: "policy-bar", role: "note", children: [_jsx("span", { className: "policy-dot", "aria-hidden": "true", children: "i" }), _jsx("span", { children: policyNote })] })), _jsxs(ThreadPrimitive.Root, { className: "thread", children: [_jsxs("div", { className: "thread-wrap", children: [_jsxs(ThreadPrimitive.Viewport, { className: "viewport", children: [_jsx(ThreadPrimitive.Empty, { children: _jsxs("div", { className: "welcome", children: [_jsx("p", { children: welcome ?? branding.welcome ?? "有什么可以帮你?" }), (suggestions ?? branding.suggestions ?? []).map((s) => (_jsx("button", { className: "chip", onClick: () => send(s), children: s }, s)))] }) }), _jsx(ToolLabels.Provider, { value: toolLabels, children: _jsx(CardRenderer.Provider, { value: renderCard ?? (() => null), children: _jsx(ThreadPrimitive.Messages, { components: { UserMessage, UserEditComposer, AssistantMessage } }) }) }), _jsx(AuiIf, { condition: (s) => s.thread.isRunning, children: _jsx(RunningIndicator, {}) })] }), _jsx(ThreadPrimitive.ScrollToBottom, { className: "scroll-bottom", title: "\u6EDA\u52A8\u5230\u6700\u65B0", children: "\u2193" })] }), confirms.length > 0 && (_jsx("div", { className: "confirms", children: confirms.map((c) => (_jsx(ConfirmCard, { request: c, onAnswer: (allow) => answerConfirm(c, allow) }, c.toolCallId))) })), notices.length > 0 && (_jsx("div", { className: "notices", children: notices.map((n) => (_jsx("div", { className: `notice ${n.level}`, children: n.message }, n.key))) })), uiPrompts.length > 0 && (_jsx("div", { className: "confirms", children: uiPrompts.map((p) => (_jsx(UIPromptCard, { prompt: p, onAnswer: (a) => answerUI(p, a) }, p.id))) })), queue.length > 0 && _jsx(QueueBar, { queue: queue, onSteer: steer, onDrop: drop }), usage && (_jsxs("div", { className: "statusbar", children: ["\u672C\u6B21\u7528\u91CF ", usage.total, " tokens\uFF08\u8F93\u5165 ", usage.input, " / \u8F93\u51FA ", usage.output, "\uFF09"] })), _jsx(Composer, { running: running, commands: commands, tiers: branding.tiers, tier: tier, onTier: onTier, onSend: send, onStop: () => runtime.thread.cancelRun() }), _jsx(Lightbox, {})] })] }) }));
|
|
163
|
+
return (_jsx(AssistantRuntimeProvider, { runtime: runtime, children: _jsx(SlotsProvider, { value: slots, children: _jsxs("div", { className: "chat", children: [_jsxs("header", { className: "chatbar", children: [branding.logo ? _jsx("img", { className: "logo", src: branding.logo, alt: "" }) : null, _jsx("h1", { children: title ?? branding.title }), _jsx(ThemeToggle, {})] }), policyNote && (_jsxs("p", { className: "policy-bar", role: "note", children: [_jsx("span", { className: "policy-dot", "aria-hidden": "true", children: "i" }), _jsx("span", { children: policyNote })] })), _jsxs(ThreadPrimitive.Root, { className: "thread", children: [_jsxs("div", { className: "thread-wrap", children: [_jsxs(ThreadPrimitive.Viewport, { className: "viewport", children: [_jsx(ThreadPrimitive.Empty, { children: _jsxs("div", { className: "welcome", children: [_jsx("p", { children: welcome ?? branding.welcome ?? "有什么可以帮你?" }), (suggestions ?? branding.suggestions ?? []).map((s) => (_jsx("button", { className: "chip", onClick: () => send(s), children: s }, s)))] }) }), _jsx(ToolLabels.Provider, { value: toolLabels, children: _jsx(CardRenderer.Provider, { value: renderCard ?? (() => null), children: _jsx(ThreadPrimitive.Messages, { components: { UserMessage, UserEditComposer, AssistantMessage } }) }) }), _jsx(AuiIf, { condition: (s) => s.thread.isRunning, children: _jsx(RunningIndicator, {}) })] }), _jsx(ThreadPrimitive.ScrollToBottom, { className: "scroll-bottom", title: "\u6EDA\u52A8\u5230\u6700\u65B0", children: "\u2193" })] }), _jsx(FollowUpSuggestions, {}), confirms.length > 0 && (_jsx("div", { className: "confirms", children: confirms.map((c) => (_jsx(ConfirmCard, { request: c, onAnswer: (allow) => answerConfirm(c, allow) }, c.toolCallId))) })), notices.length > 0 && (_jsx("div", { className: "notices", children: notices.map((n) => (_jsx("div", { className: `notice ${n.level}`, children: n.message }, n.key))) })), uiPrompts.length > 0 && (_jsx("div", { className: "confirms", children: uiPrompts.map((p) => (_jsx(UIPromptCard, { prompt: p, onAnswer: (a) => answerUI(p, a) }, p.id))) })), queue.length > 0 && _jsx(QueueBar, { queue: queue, onSteer: steer, onDrop: drop }), usage && (_jsxs("div", { className: "statusbar", children: ["\u672C\u6B21\u7528\u91CF ", usage.total, " tokens\uFF08\u8F93\u5165 ", usage.input, " / \u8F93\u51FA ", usage.output, "\uFF09"] })), _jsx(Composer, { running: running, commands: commands, tiers: branding.tiers, tier: tier, onTier: onTier, onSend: send, attachIconSpec: branding.ui?.icons?.attachment, onStop: () => runtime.thread.cancelRun() }), _jsx(Lightbox, {})] })] }) }) }));
|
|
147
164
|
}
|
|
148
165
|
/** Shown while a run is streaming: animated dots + seconds since this run's
|
|
149
166
|
* indicator mounted (unmount/remount per run resets the counter by design). */
|
|
@@ -254,7 +271,8 @@ function ToolCard({ toolName, result, isError, status }) {
|
|
|
254
271
|
const blocked = !isError && Boolean(view.details?.blocked);
|
|
255
272
|
return (_jsxs("div", { className: `tool${isError ? " err" : blocked ? " blocked" : ""}`, children: [_jsxs("div", { className: "tool-head", children: [_jsx("span", { className: "tool-name", children: labels[toolName] ?? "调用工具" }), pending && _jsx("span", { className: "tool-run", children: "\u6267\u884C\u4E2D\u2026" }), !pending && isError && _jsx("span", { className: "tool-run bad", children: "\u2717 \u5931\u8D25" }), !pending && blocked && _jsx("span", { className: "tool-run warn", children: "\u26D4 \u53D7\u9650" }), !pending && !isError && !blocked && _jsx("span", { className: "tool-run ok", children: "\u2713 \u5B8C\u6210" })] }), blocked && view.details?.user_message && _jsx("p", { className: "tool-blocked", children: view.details.user_message }), !pending && !isError && !blocked && _jsx(CardSlot, { details: view.details }), isError && view.text && _jsx("pre", { className: "tool-err-text", children: view.text })] }));
|
|
256
273
|
}
|
|
257
|
-
function Composer({ running, commands, tiers, tier, onTier, onSend, onStop, }) {
|
|
274
|
+
function Composer({ running, commands, tiers, tier, onTier, onSend, attachIconSpec, onStop, }) {
|
|
275
|
+
const { Icon } = useSlots();
|
|
258
276
|
const [text, setText] = useState("");
|
|
259
277
|
const [images, setImages] = useState([]);
|
|
260
278
|
// B4-A: converted documents, held as finished text — the heavy parsing has
|
|
@@ -351,5 +369,5 @@ function Composer({ running, commands, tiers, tier, onTier, onSend, onStop, }) {
|
|
|
351
369
|
}, placeholder: running ? "输入追加需求,将在当前回答后执行…" : "输入问题,Enter 发送(可粘贴或选择图片/文档)" }), _jsx("input", { ref: fileRef, type: "file", accept: "image/png,image/jpeg,image/webp,image/gif,.md,.markdown,.txt,.log,.json,.yaml,.yml,.csv,.tsv,.pdf,.docx,.xlsx,.xlsm", multiple: true, hidden: true, onChange: (e) => {
|
|
352
370
|
void pick(e.target.files);
|
|
353
371
|
e.target.value = "";
|
|
354
|
-
} }), _jsx("button", { type: "button", className: "attach-btn", title: "\u6DFB\u52A0\u56FE\u7247\u6216\u6587\u6863\uFF08\u5404\u6700\u591A 4 \u4E2A\uFF09", onClick: () => fileRef.current?.click(), children:
|
|
372
|
+
} }), _jsx("button", { type: "button", className: "attach-btn", title: "\u6DFB\u52A0\u56FE\u7247\u6216\u6587\u6863\uFF08\u5404\u6700\u591A 4 \u4E2A\uFF09", onClick: () => fileRef.current?.click(), children: _jsx(Icon, { spec: attachIconSpec }) }), tiers && tiers.length > 0 && _jsx(TierPicker, { tiers: tiers, value: tier, onChange: onTier }), running ? (_jsx("button", { className: "stop", onClick: onStop, children: "\u505C\u6B62" })) : (_jsx("button", { className: "send", disabled: (!text.trim() && images.length === 0 && docs.length === 0) || docBusy !== null, onClick: submit, children: "\u53D1\u9001" }))] }));
|
|
355
373
|
}
|
package/dist/AgentChatApp.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { BrandingResponse } from "@njuptlzf/agent-chat-protocol";
|
|
3
|
+
import type { Slots } from "./ui/slots.tsx";
|
|
3
4
|
/**
|
|
4
5
|
* agentChat 本体(可独立开源的一层):自己的侧栏(新会话+历史会话)加对话。
|
|
5
6
|
* 零业务知识——标题/欢迎语/档位/指令全部来自服务端 branding 与协议。
|
|
6
7
|
*/
|
|
7
|
-
export default function AgentChatApp({ branding, scope, renderCard, persona, title, policyNote, welcome, suggestions, compact, showBrand, assistantLabel, }: {
|
|
8
|
+
export default function AgentChatApp({ branding, scope, renderCard, slots, persona, title, policyNote, welcome, suggestions, compact, showBrand, assistantLabel, }: {
|
|
8
9
|
branding: BrandingResponse;
|
|
9
10
|
/** Qualification the default persona answers for; undefined runs the product default. */
|
|
10
11
|
scope?: string;
|
|
11
12
|
/** 产物卡渲染器(产品注入,透传给平台聊天组件)。 */
|
|
12
13
|
renderCard?: (details: unknown) => ReactNode;
|
|
14
|
+
/** 视觉件槽位覆盖(可插拔,见 ui/slots.tsx)。 */
|
|
15
|
+
slots?: Partial<Slots>;
|
|
13
16
|
/**
|
|
14
17
|
* 人格:undefined = 产品默认助手。会话列表也按它过滤(见 visibleSessions)。
|
|
15
18
|
* id 由产品 manifest 声明,core 不认识具体名字(通用化)。
|
package/dist/AgentChatApp.js
CHANGED
|
@@ -11,7 +11,7 @@ import { useNarrow } from "./ui/useNarrow.js";
|
|
|
11
11
|
* agentChat 本体(可独立开源的一层):自己的侧栏(新会话+历史会话)加对话。
|
|
12
12
|
* 零业务知识——标题/欢迎语/档位/指令全部来自服务端 branding 与协议。
|
|
13
13
|
*/
|
|
14
|
-
export default function AgentChatApp({ branding, scope, renderCard, persona, title, policyNote, welcome, suggestions, compact = false, showBrand = false, assistantLabel = "助手", }) {
|
|
14
|
+
export default function AgentChatApp({ branding, scope, renderCard, slots, persona, title, policyNote, welcome, suggestions, compact = false, showBrand = false, assistantLabel = "助手", }) {
|
|
15
15
|
const [active, setActive] = useState({ key: 0 });
|
|
16
16
|
const [sessions, setSessions] = useState(null);
|
|
17
17
|
// 不同人格各看各的历史:混在一起的话,点开对方那条就是 persona_mismatch。
|
|
@@ -85,6 +85,6 @@ export default function AgentChatApp({ branding, scope, renderCard, persona, tit
|
|
|
85
85
|
}
|
|
86
86
|
setActive((a) => ({ key: a.key + 1, sessionId: s.sessionId, initialMessages }));
|
|
87
87
|
};
|
|
88
|
-
const chat = (_jsx(ChatApp, { branding: branding, persona: persona, title: title, policyNote: policyNote, welcome: welcome, suggestions: suggestions, sessionId: active.sessionId, initialMessages: active.initialMessages, tier: tier, scope: scope, renderCard: renderCard, onTier: setTier, commands: commands, onRunEnd: reloadSessions }, active.key));
|
|
88
|
+
const chat = (_jsx(ChatApp, { branding: branding, persona: persona, title: title, policyNote: policyNote, welcome: welcome, suggestions: suggestions, sessionId: active.sessionId, initialMessages: active.initialMessages, tier: tier, scope: scope, renderCard: renderCard, slots: slots, onTier: setTier, commands: commands, onRunEnd: reloadSessions }, active.key));
|
|
89
89
|
return (_jsxs("div", { className: "ac-row", children: [_jsxs("aside", { className: `side acnav${shownCollapsed ? " collapsed" : ""}`, style: { flexBasis: nav.width }, children: [showBrand && (_jsxs("div", { className: "brand", children: [branding.logo ? _jsx("img", { className: "logo", src: branding.logo, alt: "" }) : null, _jsx("span", { children: branding.title })] })), _jsx("button", { className: "newchat", onClick: newSession, title: "\u91CD\u65B0\u5F00\u59CB\u4E00\u4E2A\u4F1A\u8BDD", children: "\uFF0B \u65B0\u4F1A\u8BDD" }), _jsxs("div", { className: "hist-h", children: ["\u5386\u53F2\u4F1A\u8BDD", _jsx("button", { className: "collapse-btn", onClick: toggleCollapsed, title: "\u6536\u8D77\u4FA7\u680F", children: "\u00AB" })] }), _jsx("div", { className: "sessions", children: sessions === null ? (_jsx("div", { className: "s-empty", children: "\u52A0\u8F7D\u4E2D\u2026" })) : visibleSessions.length === 0 ? (_jsx("div", { className: "s-empty", children: "\u6682\u65E0\u5386\u53F2\u4F1A\u8BDD" })) : (groupSessions(visibleSessions, new Date()).map((g) => (_jsxs("div", { children: [_jsx("div", { className: "s-group", children: g.label }), g.items.map((s) => (_jsxs("button", { className: "s-item", title: s.title, onClick: () => void openSession(s), children: [_jsx("span", { className: "s-title", children: s.title }), _jsxs("span", { className: "s-meta", children: [relativeTime(s.updatedAt, new Date()), " \u00B7 ", s.messageCount, " \u6761"] })] }, s.sessionId)))] }, g.label)))) })] }), !shownCollapsed && _jsx(Splitter, { ...nav.handlers }), shownCollapsed && (_jsxs("button", { className: "side-open", onClick: toggleCollapsed, title: "\u5C55\u5F00\u5386\u53F2\u4F1A\u8BDD\u4FA7\u680F", "aria-label": "\u5C55\u5F00\u5386\u53F2\u4F1A\u8BDD\u4FA7\u680F", children: [_jsx("span", { className: "side-open-arrow", children: "\u00BB" }), _jsx("span", { className: "side-open-text", children: "\u5386\u53F2" })] })), _jsx("main", { className: "content", children: chat })] }));
|
|
90
90
|
}
|
package/dist/PersonasPage.js
CHANGED
|
@@ -3,6 +3,7 @@ import { useCallback, useEffect, useState } from "react";
|
|
|
3
3
|
import { apiHeaders, auth } from "./auth.js";
|
|
4
4
|
import { fetchJson } from "./sse.js";
|
|
5
5
|
import { fmtTime } from "./ui/timefmt.js";
|
|
6
|
+
const FOLLOW_UP_OPTIONS = ["off", "static", "llm"];
|
|
6
7
|
const UI_FIELDS = [
|
|
7
8
|
{ key: "label", label: "入口名" },
|
|
8
9
|
{ key: "icon", label: "图标" },
|
|
@@ -14,6 +15,8 @@ const UI_FIELDS = [
|
|
|
14
15
|
{ key: "policyNote", label: "常驻提示条", multiline: true },
|
|
15
16
|
// 快捷问法是一组(表里叫 suggestions):一行一条,空行忽略。
|
|
16
17
|
{ key: "suggestions", label: "快捷问法(一行一条)", multiline: true, list: true },
|
|
18
|
+
// 轮次结束后的下一步建议:闭合三态,用下拉而不是文本框——打错值会被服务端 400。
|
|
19
|
+
{ key: "followUpMode", label: "下一步建议", options: FOLLOW_UP_OPTIONS },
|
|
17
20
|
];
|
|
18
21
|
const SOURCE_TEXT = { manifest: "manifest", file: "已改", draft: "草稿" };
|
|
19
22
|
const ACTION_TEXT = { save: "保存", reset: "恢复默认", rollback: "回滚" };
|
|
@@ -311,6 +314,11 @@ export default function PersonasPage() {
|
|
|
311
314
|
}
|
|
312
315
|
setUi(next);
|
|
313
316
|
};
|
|
317
|
+
// 闭合枚举用下拉:空项 = 清掉覆盖回落出厂值(manifest 值就是默认值)。
|
|
318
|
+
if (f.options) {
|
|
319
|
+
const globalOff = list?.globalFollowUpMode === "off";
|
|
320
|
+
return (_jsxs(_Fragment, { children: [_jsxs("select", { "data-field": f.key, value: value, disabled: globalOff, onChange: (e) => onChange(e.target.value), children: [_jsx("option", { value: "", children: placeholder ? `用出厂值(${placeholder})` : "用出厂值 / 跟随全局" }), f.options.map((o) => (_jsx("option", { value: o, children: o }, o)))] }), globalOff && _jsx("span", { children: "\u5168\u5C40\u5DF2\u5173\u95ED\uFF0C\u6B64\u9879\u6682\u4E0D\u751F\u6548" })] }));
|
|
321
|
+
}
|
|
314
322
|
return f.multiline ? (_jsx("textarea", { "data-field": f.key, rows: f.list ? 3 : 2, value: value, placeholder: placeholder, onChange: (e) => onChange(e.target.value) })) : (_jsx("input", { "data-field": f.key, value: value, placeholder: placeholder, onChange: (e) => onChange(e.target.value) }));
|
|
315
323
|
})()] }, f.key))) }), detail.id === list.defaultPersona && (_jsxs("p", { className: "ps-note", children: ["\u9ED8\u8BA4\u52A9\u624B\u6CA1\u6709\u4FA7\u680F\u5165\u53E3\uFF1A", _jsx("b", { children: "\u56FE\u6807 / \u6807\u7B7E / \u60AC\u505C\u63D0\u793A" }), "\u76EE\u524D\u6CA1\u6709\u5C55\u793A\u4F4D\u7F6E\uFF1B", _jsx("b", { children: "\u5165\u53E3\u540D" }), "\u7528\u5728\u804A\u5929\u7A97\u6807\u9898\uFF0C", _jsx("b", { children: "\u7A7A\u6001\u6807\u9898 / \u63D0\u793A\u6761 / \u5FEB\u6377\u95EE\u6CD5" }), "\u7528\u5728\u5BF9\u8BDD\u7A7A\u6001\u3002"] }))] }), _jsxs("section", { className: "ps-sec", children: [_jsxs("div", { className: "ps-sec-head", children: [_jsx("h3", { children: "\u80FD\u529B\u9762\uFF08\u53EA\u8BFB\uFF09" }), _jsx("span", { className: "ps-note", children: "\u6765\u81EA manifest\uFF0C\u6539\u5B83\u8981\u6539\u4EE3\u7801 + review\uFF1B\u8FD9\u91CC\u53EA\u80FD\u4E34\u65F6\u505C\u7528" })] }), allow === null ? (_jsx("p", { className: "ps-note", children: "\u8BE5\u4EBA\u683C\u6CA1\u6709\u5DE5\u5177\u767D\u540D\u5355\uFF08= \u4E0D\u9650\uFF09\u3002\u505C\u7528\u4ECD\u7136\u751F\u6548\uFF0C\u4F46\u767D\u540D\u5355\u672C\u8EAB\u4E0D\u5728\u8FD9\u91CC\u6539\u3002" })) : allow.length === 0 ? (_jsx("p", { className: "ps-note", children: "\u767D\u540D\u5355\u662F\u7A7A\u6570\u7EC4\uFF1A\u4E00\u4E2A\u5DE5\u5177\u90FD\u4E0D\u7ED9\uFF08\u4E0D\u662F\u300C\u5168\u7ED9\u300D\uFF09\u3002" })) : (_jsx("ul", { className: "ps-tools", children: candidates.map((name) => (_jsx("li", { children: _jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: disabled.includes(name), onChange: (e) => {
|
|
316
324
|
setDisabled((cur) => (e.target.checked ? [...cur, name] : cur.filter((n) => n !== name)));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(o){throw new Error('Could not dynamically require "'+o+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}export{r as c};
|